<?php
include("../../share/config.php");
$building = $_POST['bud'];
$day = $_POST['date'];
$id = $_POST['stid'];
$st = $_POST['st'];
$et = $_POST['et'];
$cr_id = $_POST['where'];

$arr = array();
$sql="SELECT * from cr where cr_id= '$cr_id' AND da = '$day'";
$result=mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
array_push($arr,$row['s_time'],$row['e_time']);
}
asort($arr);
$narr = array();
foreach($arr as $x=>$xv){
array_push($narr,$xv);
}
$sql = "INSERT INTO `Lib`.`cr`(building,cr_id,da,s_time,e_time,user_id,sta) VALUES('{$building}','{$cr_id}','{$day}','{$st}','{$et}','{$id}','1')";

$insert = mysqli_query($conn,$sql);  
mysqli_close($conn);
Header("Location:../../pages/admin/classroom.php");

?>